package de.gwtprime.client.activities;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

import de.gwtprime.client.ClientFactory;
import de.gwtprime.client.places.WelcomePlace;
import de.gwtprime.client.util.AppUtils;
import de.gwtprime.client.views.WelcomeView;
import de.gwtprime.client.viewsStatic.NavigationViewImpl.Section;

public class WelcomeActivity extends AbstractActivity implements WelcomeView.Presenter{

	private ClientFactory clientFactory;
	private String name;
	public WelcomeActivity(WelcomePlace place, ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
		this.name = place.getName();
	}
	
	
	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		
		AppUtils.trackPageview("Home");
		
		WelcomeView welcomeView = clientFactory.getWelcomeView();
		welcomeView.setPresenter(this);
		welcomeView.setClientFactory(clientFactory);
		welcomeView.setName(name);
		panel.setWidget(welcomeView.asWidget());
		
		clientFactory.getNavigationView().activateSection(Section.HOME);
	}


	@Override
	public void goTo(Place place) {
		clientFactory.getPlaceController().goTo(place);
		
	}

}
